package com.xuyiwei.xblog.core.base.constant.enums;

import com.xuyiwei.xblog.core.base.constant.ConstantStatusInterface;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by xuyiwei on 2018/10/10.
 */
public enum SourceEnum implements ConstantStatusInterface<String,String>{

    NULL("", ""),
    GITHUB("GITHUB", "GITHUB"),
    WEIBO("WEIBO", "微博"),
    QQ("QQ", "QQ"),
    XBLOG("XBLOG", "XBLOG");


    private String key;
    private String desc;

    SourceEnum(String key, String desc) {
        this.key = key;
        this.desc = desc;
    }

    static Map<String, SourceEnum> map = new HashMap<>();

    static {
        for (SourceEnum bst : SourceEnum.values()) {
            map.put(bst.key, bst);
        }
    }

    public static SourceEnum convert(String key) {
        SourceEnum type = map.get(key);
        return (type != null) ? type : NULL;
    }

    @Override
    public String getKey() {
        return key;
    }

    @Override
    public String getDesc() {
        return desc;
    }
}
